#include "qjsonconfig.h"

QJsonConfig::QJsonConfig(QObject *parent)
    : QObject{parent}
{
    ReadConfigFile();
}

QString QJsonConfig::GetId()
{
    return m_sId;
}

QString QJsonConfig::GetSecret()
{
    return m_sSecret;
}

void QJsonConfig::ReadConfigFile()
{
    QFile loadFile(QStringLiteral("config.json"));

    if (!loadFile.open(QIODevice::ReadOnly)) {
        qWarning("Couldn't open save file.");
        return;
    }

    QByteArray saveData = loadFile.readAll();

    QJsonDocument loadDoc(QJsonDocument::fromJson(saveData));

    QJsonObject object = loadDoc.object();

    m_sId = object["id"].toString();
    m_sSecret = object["secret"].toString();
}
